
local utf8 = require 'dclm.text.codecs.utf8'

for c in utf8.eachcharcode('Hello World') do
  print(string.format('U+%04X',c))
end

print(utf8.makestring(utf8.eachcharcode('Hello World')))

local unicodedata = require 'dclm.text.unicodedata'

print(utf8.makestring(unicodedata.eachtoupper(utf8.eachcharcode('Hello World'))))
print(utf8.makestring(unicodedata.eachtolower(utf8.eachcharcode('Hello World'))))

print('original:')
for c in utf8.eachcharcode('ϓ') do
  print(string.format('U+%04X',c))
end
print('canonical decomposed (NFD):')
for c in unicodedata.eachdecompose(false, utf8.eachcharcode('ϓ')) do
  print(string.format('U+%04X',c))
end
print('compatible decomposed (NFKD):')
for c in unicodedata.eachdecompose(true, utf8.eachcharcode('ϓ')) do
  print(string.format('U+%04X',c))
end

print('canonical composed (NFC):')
for c in unicodedata.eachcompose(unicodedata.eachdecompose(false, utf8.eachcharcode('ϓ'))) do
  print(string.format('U+%04X',c))
end
print('compatible composed (NFKC):')
for c in unicodedata.eachcompose(unicodedata.eachdecompose(true, utf8.eachcharcode('ϓ'))) do
  print(string.format('U+%04X',c))
end
